

package personas.model;
import java.sql.ResultSet;
import model.BasicBean;




public class Persona extends BasicBean {


        public String   nombreCompleto      = "";
        public String   direccion           = "";
        public String   trelefono           = "";
        public String   email               = "";

        public Persona() {
        }

        public Persona( ResultSet rs ) {
                try {
                        id                  = validateString( rs.getString( "id" ) );
                        nombreCompleto      = validateString( rs.getString( "nombreCompleto" ) );
                        direccion           = validateString( rs.getString( "direccion" ) );
                        trelefono           = validateString( rs.getString( "trelefono" ) );
                        email               = validateString( rs.getString( "email" ) );
                } catch ( Exception e ) { System.out.println( e ); }
        }

    @Override
        public String getUpdateSql() {
                String sql = "";
                if( id.equals( "" ) ){
                        sql = "insert into Persona( nombreCompleto, direccion, trelefono, email ) values( '" +
                        nombreCompleto + "', '" +
                        direccion + "', '" +
                        trelefono + "', '" +
                        email + "' )";
                } else {
                        sql = "update Persona set nombreCompleto = '" +
                        nombreCompleto + "', direccion= '" +
                        direccion + "', trelefono= '" +
                        trelefono + "', email= '" +
                        email + "' where id = '" + id + "'";
                }
           return sql;
        }



    @Override
    public String getHtmlRow() {
        String sz = "";

        sz += ("<td class='st4middle'>" + nombreCompleto + "</td>");
        sz += ("<td class='st4middle'>" + direccion + "</td>");
        sz += ("<td class='st4middle'>" + trelefono + "</td>");
        sz += ("<td class='st4middle'>" + email + "</td>");
        
        return sz;
      }




      @Override
    public String getIdentifier() {
        return "idPersona=" + id;
    }



   }
